package com.example.spzx.controller;

import com.example.spzx.Service.SysRoleMenuService;
import com.example.spzx.model.dto.system.AssginMenuDto;
import com.example.spzx.model.entity.system.SysRoleMenu;
import com.example.spzx.model.vo.common.Result;
import com.example.spzx.model.vo.common.ResultCodeEnum;
import com.example.spzx.model.vo.system.SysMenuVo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("/admin/system/sysRoleMenu")
@RestController
public class SysRoleMenuController {
    @Resource
    private SysRoleMenuService sysRoleMenuService;
    @GetMapping("/findSysRoleMenuByRoleId/{roleId}")
    public Result<SysRoleMenu> findSysRoleMenuByRoleId(@PathVariable("roleId") Integer roleId){
        Map<String,Object> map=sysRoleMenuService.getlist(roleId);
        return Result.build(map, ResultCodeEnum.SUCCESS);


    }
    @PostMapping("/doAssign")
    public Result<SysRoleMenu> doAssign(@RequestBody AssginMenuDto assginMenuDto){
        sysRoleMenuService.doassign(assginMenuDto);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }
    @GetMapping("/rulemenu")
    public Result<SysMenuVo> rulemenu(@RequestHeader String token){

        List<SysMenuVo> list=sysRoleMenuService.getrulelist(token);
        return Result.build(list,ResultCodeEnum.SUCCESS);
    }
}
